Skip to content

Adding applyMatrix#4200

Draft
MichaelABurr wants to merge 2 commits into
Macaulay2:developmentfrom
MichaelABurr:development
Draft

Adding applyMatrix#4200
MichaelABurr wants to merge 2 commits into
Macaulay2:developmentfrom
MichaelABurr:development

Conversation

@MichaelABurr

Copy link
Copy Markdown
Member

Adding applyMatrix to apply a function to all entries of a matrix at once.

@pzinn

pzinn commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

why not add a method to apply?

@MichaelABurr

Copy link
Copy Markdown
Member Author

why not add a method to apply?

apply is defined in the D-level, so any additions to apply would need to be done there. I'm not sure of a clean way to access a matrix in the D-level, but perhaps there's a way to do that (if anyone knows, please send suggestions). Alternately, one could wrap the apply from the D-level to make a top level function that calls the D-code, except on matrices. This also unprotects apply, so, we'd also have to protect it.

@MichaelABurr MichaelABurr marked this pull request as draft April 20, 2026 01:59
@pzinn

pzinn commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

while I'm not a big fan of the whole D-level-function-wrapper, we've done it so many times already that why not here...

@MichaelABurr

Copy link
Copy Markdown
Member Author

while I'm not a big fan of the whole D-level-function-wrapper, we've done it so many times already that why not here...

I don't have anything against this alternate approach. I just picked an easy one to start the conversation.

@mahrud mahrud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little redundant with applyTable, but could be useful. Could you add docs and ideally a test though, perhaps near those of applyTable?

I think the reason this isn't already existing is that with matrices fixing the source and target is usually necessary, so I usually use map(tar, src, applyTable(entries m, blah)) instead. However, for mutable matrices we don't care about source and target, so it would be great if you could also add support for MutableMatrix input.

@mahrud

mahrud commented Apr 20, 2026

Copy link
Copy Markdown
Member

Also, could you edit the PR title?

@MichaelABurr MichaelABurr changed the title Development Adding applyMatrix Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants